home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / test / test_hexoct.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2005-10-18  |  3KB  |  100 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.4)
  3.  
  4. '''Test correct treatment of hex/oct constants.
  5.  
  6. This is complex because of changes due to PEP 237.
  7. '''
  8. import sys
  9. platform_long_is_32_bits = sys.maxint == 2147483647
  10. import unittest
  11. from test import test_support
  12. import warnings
  13. warnings.filterwarnings('ignore', 'hex/oct constants', FutureWarning, '<string>')
  14.  
  15. class TextHexOct(unittest.TestCase):
  16.     
  17.     def test_hex_baseline(self):
  18.         self.assertEqual(0, 0)
  19.         self.assertEqual(16, 16)
  20.         if platform_long_is_32_bits:
  21.             self.assertEqual(2147483647, 2147483647)
  22.         else:
  23.             self.assertEqual(0x7FFFFFFFFFFFFFFFL, 0x7FFFFFFFFFFFFFFFL)
  24.         self.assertEqual(-0, 0)
  25.         self.assertEqual(-16, -16)
  26.         if platform_long_is_32_bits:
  27.             self.assertEqual(-2147483647, -2147483647)
  28.         else:
  29.             self.assertEqual(-0x7FFFFFFFFFFFFFFFL, -0x7FFFFFFFFFFFFFFFL)
  30.         self.assertEqual(-0, 0)
  31.         self.assertEqual(-16, -16)
  32.         if platform_long_is_32_bits:
  33.             self.assertEqual(-2147483647, -2147483647)
  34.         else:
  35.             self.assertEqual(-0x7FFFFFFFFFFFFFFFL, -0x7FFFFFFFFFFFFFFFL)
  36.  
  37.     
  38.     def test_hex_unsigned(self):
  39.         if platform_long_is_32_bits:
  40.             self.assertEqual(0x80000000L, 0x80000000L)
  41.             self.assertEqual(0xFFFFFFFFL, 0xFFFFFFFFL)
  42.             self.assertEqual(-0x80000000L, -0x80000000L)
  43.             self.assertEqual(-0xFFFFFFFFL, -0xFFFFFFFFL)
  44.             self.assertEqual(-0x80000000L, -0x80000000L)
  45.             self.assertEqual(-0xFFFFFFFFL, -0xFFFFFFFFL)
  46.         else:
  47.             self.assertEqual(0x8000000000000000L, 0x8000000000000000L)
  48.             self.assertEqual(0xFFFFFFFFFFFFFFFFL, 0xFFFFFFFFFFFFFFFFL)
  49.             self.assertEqual(-0x8000000000000000L, -0x8000000000000000L)
  50.             self.assertEqual(-0xFFFFFFFFFFFFFFFFL, -0xFFFFFFFFFFFFFFFFL)
  51.             self.assertEqual(-0x8000000000000000L, -0x8000000000000000L)
  52.             self.assertEqual(-0xFFFFFFFFFFFFFFFFL, -0xFFFFFFFFFFFFFFFFL)
  53.  
  54.     
  55.     def test_oct_baseline(self):
  56.         self.assertEqual(0, 0)
  57.         self.assertEqual(16, 16)
  58.         if platform_long_is_32_bits:
  59.             self.assertEqual(2147483647, 2147483647)
  60.         else:
  61.             self.assertEqual(0x7FFFFFFFFFFFFFFFL, 0x7FFFFFFFFFFFFFFFL)
  62.         self.assertEqual(-0, 0)
  63.         self.assertEqual(-16, -16)
  64.         if platform_long_is_32_bits:
  65.             self.assertEqual(-2147483647, -2147483647)
  66.         else:
  67.             self.assertEqual(-0x7FFFFFFFFFFFFFFFL, -0x7FFFFFFFFFFFFFFFL)
  68.         self.assertEqual(-0, 0)
  69.         self.assertEqual(-16, -16)
  70.         if platform_long_is_32_bits:
  71.             self.assertEqual(-2147483647, -2147483647)
  72.         else:
  73.             self.assertEqual(-0x7FFFFFFFFFFFFFFFL, -0x7FFFFFFFFFFFFFFFL)
  74.  
  75.     
  76.     def test_oct_unsigned(self):
  77.         if platform_long_is_32_bits:
  78.             self.assertEqual(0x80000000L, 0x80000000L)
  79.             self.assertEqual(0xFFFFFFFFL, 0xFFFFFFFFL)
  80.             self.assertEqual(-0x80000000L, -0x80000000L)
  81.             self.assertEqual(-0xFFFFFFFFL, -0xFFFFFFFFL)
  82.             self.assertEqual(-0x80000000L, -0x80000000L)
  83.             self.assertEqual(-0xFFFFFFFFL, -0xFFFFFFFFL)
  84.         else:
  85.             self.assertEqual(0x8000000000000000L, 0x8000000000000000L)
  86.             self.assertEqual(0xFFFFFFFFFFFFFFFFL, 0xFFFFFFFFFFFFFFFFL)
  87.             self.assertEqual(-0x8000000000000000L, -0x8000000000000000L)
  88.             self.assertEqual(-0xFFFFFFFFFFFFFFFFL, -0xFFFFFFFFFFFFFFFFL)
  89.             self.assertEqual(-0x8000000000000000L, -0x8000000000000000L)
  90.             self.assertEqual(-0xFFFFFFFFFFFFFFFFL, -0xFFFFFFFFFFFFFFFFL)
  91.  
  92.  
  93.  
  94. def test_main():
  95.     test_support.run_unittest(TextHexOct)
  96.  
  97. if __name__ == '__main__':
  98.     test_main()
  99.  
  100.